/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package vn.webapp.service;

import java.util.ArrayList;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service;
import vn.webapp.dao.SessionsDAO;
import vn.webapp.dto.DataPage;
import vn.webapp.model.Classes;
import vn.webapp.model.Sessions;

@Service("sessionsService")
public class SessionsServiceImpl implements SessionsService {

    @Autowired
    private SessionsDAO sessionsDAO;

    /**
     *
     * @return
     */
    @Override
    public DataPage<Sessions> list() {
        DataPage<Sessions> dataSessions = new DataPage<>();
        dataSessions.setData(sessionsDAO.list());
        return dataSessions;
    }

    @Override
    public Sessions viewDetail(String id) {
        return sessionsDAO.viewDetail(id);
    }

    @Override
    public Sessions checkExistsYear(String year, int semester,  int id) {
        return sessionsDAO.checkExistsYear(year, semester, id);
    }

    @Override
    public int updateTheSession(String year, int semester, int id) {
        return sessionsDAO.updateTheSession(year, semester, id);
    }

    @Override
    public int removeSession(int id) {
        return sessionsDAO.removeSession(id);
    }
    
    @Override
    public int saveASession(String year, int semester)
    {
        Sessions session = new Sessions();
        session.setSemester(semester);
        session.setYear(year);
        return sessionsDAO.saveASession(session);
    }
}
